/**
获取指定URL的内容
go build fetch
fetch.exe https://www.baidu.com
或
go run fetch.go http://www.open-open.com/lib/view/open1396578860887.html
2018/7/26
wgg
*/
package main

import (
	"os"
	"net/http"
	"fmt"
	"io/ioutil"
)

func main()  {
	for _,url := range os.Args[1:] {
		resp,err := http.Get(url)//获取url中内容
		if err != nil {
			fmt.Fprintf(os.Stderr,"fetch:%v\n",err)
			os.Exit(1)
		}
		b,err := ioutil.ReadAll(resp.Body)//读取获得的信息
		resp.Body.Close()
		if err != nil {
			fmt.Fprintf(os.Stderr,"fetch:%v\n",err)
			os.Exit(1)
		}
		fmt.Printf("%s",b)
	}
}
